<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>上传商品信息</title>
	<link rel="stylesheet" href="css/select2.css">
	<style type="text/css">
		body{width: 1200px;font-size: 16px;font-family: 'Microsoft Yahei',微软雅黑;position: relative;margin:0 auto;}
		.content{float:left;padding:20px;border:2px dashed #ccc;margin-top: 20px}
		.ipt_01{width: 400px;height: 25px;line-height: 25px;padding-left: 20px}
		.item{margin:20px 0;}
		.table2{border:1px solid #ddd;}
		.table2 th{background: #eee;}
		.table2 td{text-align: center;}
		.ipt_02{height: 30px;width: 87px;border:0;outline: 0;line-height: 30px;text-align: center;}
		.sel_01{width: 70px;border-color: #fff;height: 30px;}
		.tac{text-align: center;}
		.err_msg{color: red}
	</style>
	<script src="jquery-1.7.2.min.js"></script>
	<script src="laydate/WdatePicker.js"></script>
	<script src="select2.min.js"></script>
	<script src="js/jquery.validate.min.js"></script>
	<script src="js/messages_zh.js"></script>
	<script src="js/script.js"></script>
</head>
<?php 
	session_start();
	include_once 'includes/init.php';
	$id=isset($_SESSION['id'])?$_SESSION['id']:'';
	$sql = "select id, phone, names from t_member where  id != ".$id." and rule_id = 1 order by id desc";
	$query = $db_Obj->getAll($sql);
 ?>


<body>
	<div class="head">
		<h2 style="text-align: center;">新建项目</h2>
		<a href="index.php" style="margin-left:10px;">返回列表</a><br>
	</div>
	<div class="content" >
		<div>
			<span>上传类型：</span>
			<select  id="uptype" onchange="updatetype()">
				<option value="1">提交上传</option>
				<option value="2">Excel上传</option>
			</select>
		</div>
		<div>
			<form action="proaction.php" method="POST" enctype="multipart/form-data" id="commentForm">
				  <div class="item">
				    <label  style="margin-left: 10px;">供应商：</label>
					<select class="js-example-basic-multiple" multiple="multiple" name="sid[]">
					<?php foreach ($query as $key => $value) { ?>
					    <option value="<?php echo $value['id']; ?>"><?php echo $value['names']; ?></option>
					<?php } ?>
					</select>
				  </div>
				  <div class="item">
				    <label>项目名称：</label>
				    <input type="text" name="project" class="ipt_01" placeholder="例:项目一"  required/>
				    <label for="project" class="err_msg"></label>
				  </div>
				  <div class="item">
				  	<label for="">采购类型：</label>
				  	<select name="purchase_type" style="width: 100px;">
				  		<option value="">--请选择--</option>
				  		<option value="标准">标准</option>
				  		<option value="委外">委外</option>
				  	</select>
				  </div>
				  <div class="item">
				    <label>报价截止日期：</label>
				    <input type="text"  name="lasttime" class="ipt_01 lasttime"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" onchange="check_self();"/>
				  </div>
				  <div class="item">
				    <label>报价有效时间：</label>
				    <input type="text"  name="validtime" class="ipt_01 val_date"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" />
				  </div>
				  <div class="item">
				    <label>报价失效时间：</label>
				    <input type="text"  name="invalidtime" class="ipt_01"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});" />
				  </div>
				  <div class="item">
				    <label>竞价状态：</label>
				    <input type="radio" name="status" value="1" id="aa" />
				    <label for="aa">竞价</label>
				    <input type="radio" name="status" value="0" checked="checked" id="bb" />
				    <label for="bb">非竞价</label>
				  </div>
				  <div class="item">
				    <label>密封状态：</label>
				    <input type="radio" name="mifeng" value="1" checked="checked" id="cc" />
				    <label for="cc">密封</label>
				    <input type="radio" name="mifeng" value="0"  id="dd" />
				    <label for="dd">非密封</label>
				  </div>
				<div id="putong">
					<div class="item">
					 	<table width="1000" border="1" cellspacing="0" cellpadding="0" class="table2">
					 		<tr>
					 			<th width="5"></th>
					 			<th width="40">序号</th>
					 			<th>物料编码</th>
					 			<th width="150">规格型号</th>
					 			<th width="60">计量单位</th>
					 			<th width="60">参考数量</th>
					 			<th>未税目标单价</th>
					 			<th width="30">币种</th>
					 			<th width="70">询价类型</th>
					 			<th width="70">附件</th>
					 			<th width="70">备注</th>
					 			<th width="70">物料组</th>
					 			<th width="70">采购组</th>
					 			<th width="70">工厂</th>
					 			<th width="70">配额</th>
					 		</tr>
					 		<tr class="input_table">
					 			<td><input type="checkbox" class="ipt_num"></td>
					 			<td class="num">1</td>
					 			<td><input type="text" name="type[]" class="ipt_02" required></td>
					 			<td><input type="text" name="size[]" class="ipt_02" required></td>
					 			<td>
	 				 				<select name="units[]" class="sel_01">
	 				 					<option value="">--请选择--</option>
	 							 		<option value="PCS（个）">PCS（个）</option>
	 							 		<option value="M（米）">M（米）</option>
	 							 		<option value="Kg（千克）">Kg（千克）</option>
	 							 		<option value="PRS（对）">PRS（对）</option>
	 							 		<option value="RL（卷）">RL（卷）</option>
	 							 		<option value="SET（套）">SET（套）</option>
	 							 		<option value="L（升）">L（升）</option>
	 							 		<option value="GAL（加仑）">GAL（加仑）</option>
	 							 	</select>
					 			</td>
					 			<td><input type="text" name="number[]" class="ipt_02"></td>
					 			<td><input type="text" name="price[]" class="ipt_02"></td>
					 			<td>
					 				<select name="currency[]" class="sel_01">
					 					<option value="">--请选择--</option>
	 							 		<option value="CNY">CNY</option>
	 							 		<option value="USD">USD</option>
	 							 		<option value="HKD">HKD</option>
	 							 	</select>
					 			</td>
					 			<td>
	 				 				<select name="price_type[]" class="sel_01">
	 				 					<option value="">--请选择--</option>
	 							 		<option value="密封询价">密封询价</option>
	 							 		<option value="非密封竞价">非密封竞价</option>
	 							 		<option value="非密封询价">非密封询价</option>
	 							 	</select>
					 			</td>
					 			<td><input type="file" name="file_name[]" class="ipt_02"></td>
					 			<td><input type="text" name="note[]" class="ipt_02"></td>
					 			<td>
					 				<select name="material[]" class="sel_01">
					 					<option value="">--请选择--</option>
										<option value="101 线材类">101 线材类</option>
										<option value="102 磁材类">102 磁材类</option>
										<option value="103 绝缘类">103 绝缘类</option>
										<option value="104 金属类">104 金属类</option>
										<option value="105 塑胶类">105 塑胶类</option>
										<option value="106 机械结构件类">106 机械结构件类</option>
										<option value="107 光模块结构类">107 光模块结构类</option>
										<option value="108 光器件结构类">108 光器件结构类</option>
										<option value="109 电路板类">109 电路板类</option>
										<option value="110 阻容感类">110 阻容感类</option>
										<option value="111 半导体类">111 半导体类</option>
										<option value="112 连接器类">112 连接器类</option>
										<option value="113 电气零部件类">113 电气零部件类</option>
										<option value="114 温控组件类">114 温控组件类</option>
										<option value="115 发电机组">115 发电机组</option>
										<option value="116 管芯类">116 管芯类</option>
										<option value="117 光电芯片类">117 光电芯片类</option>
										<option value="118 管芯封装材料">118 管芯封装材料</option>
										<option value="119 光纤连接器">119 光纤连接器</option>
										<option value="120 传统光学">120 传统光学</option>
										<option value="121 包材类">121 包材类</option>
										<option value="122 印刷品类">122 印刷品类</option>
										<option value="123 辅料类">123 辅料类</option>
										<option value="124 半成品">124 半成品</option>
										<option value="125 成品">125 成品</option>
										<option value="126 非生产物料">126 非生产物料</option>
										<option value="127 固定资产">127 固定资产</option>
								 	</select>
					 			</td>
					 			<td>
					 				<select name="purchase[]" class="sel_01">
					 					<option value="">--请选择--</option>
								 		<option value="8100 生产物料采购组织">8100 生产物料采购组织</option>
								 		<option value="8200 非生产物料采购组织">8200 非生产物料采购组织</option>
								 		<option value="8300 样品采购组织">8300 样品采购组织</option>
								 	</select>
					 			</td>
					 			<td>
					 				<select name="plant[]" class="sel_01">
					 					<option value="">--请选择--</option>
								 		<option value="1101 光电事业部">1101 光电事业部</option>
								 		<option value="1102 能源事业部">1102 能源事业部</option>
								 		<option value="1103 虚拟电子管理部">1103 虚拟电子管理部</option>
								 		<option value="1201 电子一部+塑膜五金事业部">1201 电子一部+塑膜五金事业部</option>
								 		<option value="1202 RJ连接器事业部">1202 RJ连接器事业部</option>
								 		<option value="1203 苹果专线">1203 苹果专线</option>
								 		<option value="1204 消费电源事业部">1204 消费电源事业部</option>
								 		<option value="1205 空">1205 空</option>
								 		<option value="1206 模具">1206 模具</option>
								 	</select>
				 				</td>
					 			<td><input type="text" name="extranum[]" class="ipt_02" /></td>
					 		</tr> 
					 	</table>
					</div>
					<div style="margin-top:20px" class="item">
						<input class="btn_01" type="button" value="增加行" onclick="addRow()">
						<input class="btn_01" type="button" value="删除行" onclick="delRow()">
					</div>
				</div>
				<div id="Excelup"  style="display: none;">
					<div class="item">
						<span>标准商品Excel上传格式：</span>
						<a href="Product.xls" download="Product.xls">模板下载</a><br>
						<span style="color:red;">(请勿修改Excel文件参数格式!!!)</span>
					</div>
					<div class="item">
						<span>格式上传：</span><input type="file" name="excelfile">
					</div>
				</div>
				<div style="text-align:center"><input style="width: 50px;margin-right:20px;" type="submit" value="提交"><input style="width: 50px;" type="reset" value="重置"></div>
			</form>
		</div>
	</div>

	<script>
		function updatetype(){
			var uptype = $("#uptype").val();
			if(uptype == 1){
				$("#putong").show();
				$("#Excelup").hide();
			}
			if(uptype == 2){
				$("#putong").hide();
				$("#Excelup").show();
			}
		}

		$(".js-example-basic-multiple").select2({
			 placeholder: "请选择供应商"
		});
	
		function addRow () {
			var num = $('.table2 tr').length;
			var addTR = $('tr.input_table:last-child').clone(true);
			addTR.appendTo(".table2");
			addTR.find('input').val('');
			addTR.find('td.num').html(num);
		}
		
		function delRow () {
			
			var num1 = $('.ipt_num:checked').length;
			var num2 = $('.table2 tr').length-1;
			var num3 =num1-num2;
			if(num1 == num2){
				alert('请至少保留一行！')
				return false;
			}
			if(num3 < 0){
				$('.table2 tr:has(.ipt_num:checked)').remove();
				change();
			}
			if(num1 == 0){
				alert('请勾选要删除的行！');
				return false;
			}
		}
		function change(){
			$('.num').each(function(i){
			$(this).html(i+1);
			})
		}
		function check_self(){
			var last_v = $('.lasttime').val();
			var dd = new Date(last_v.replace(/-/,"/")) 
			var timestamp = Date.parse(dd);
			var timestamp2 = (timestamp/1000+1).toString();
			var d = new Date(timestamp2 * 1000); 
			var last_v2 = (d.getFullYear()) + "-" + 
			           (d.getMonth() + 1) + "-" +
			           (d.getDate()) + " " + 
			           (d.getHours()) + ":" + 
			           (d.getMinutes()) + ":" + 
			           (d.getSeconds());
			$('.val_date').val(last_v2);
		}
	</script>
</body>
</html>
